package com.bey.keepgoing.webui;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.bey.keepgoing.repository.dao.AccountDao;

@Controller
@RequestMapping("/movie")
public class MovieController {

	private AccountDao accountDao;

	@RequestMapping(value = "/{name}", method = RequestMethod.GET)
	public String getMovie(@PathVariable String name, ModelMap model) {
		model.addAttribute("movie", name);
		// accountDao.save("guo", "aaa");

		UsernamePasswordToken upt = new UsernamePasswordToken("guo", "aaa");
		Subject subject = SecurityUtils.getSubject();
		subject.login(upt);

		System.out.println(subject.isAuthenticated());
		return "list";

	}

	public AccountDao getAccountDao() {
		return accountDao;
	}

	@Autowired
	public void setAccountDao(AccountDao accountDao) {
		this.accountDao = accountDao;
	}

}